Skip to content

Conversation

@MRyabchikov
Copy link

No description provided.

: data(_data), prevptr(_prev) {}
StackNode() : data(), prevptr(nullptr) {}
T data;
StackNode<T> *prevptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prev_ptr

int Pop();
Stack() : top(nullptr), size(0) {}
void push(T value);
T pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pop

void push(T value);
T pop();
T getTop();
int getSize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetSize

Stack() : top(nullptr), size(0) {}
void push(T value);
T pop();
T getTop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTop


private:
std::stack<int> data_;
StackNode<T> *top;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

top_

TEST(quickSort, Simple) {
std::vector<int> data = {1, 2, 3, 4, 5};
quickSort<int>(data);
for (auto curr : data) std::cout << curr << " ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это лишнее для теста

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ой, да, это рудимент какой-то

template <class T>
class BinaryTree {
public:
BinaryTree() : root(nullptr) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут виже только обычное дерево поиска, без балансировки, в задании дерево с балансировкой


void insert(const Key& key, const Value& value);

bool search(const Key& key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет функции которая возвращает value

if (size_ == 0) {
throw std::underflow_error("Empty stack");
}
T returning_value = top_->data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай так чуть соптимизируем:
T returning_value = std::move(top_->data);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weather_report.cpp
ну и hpp тоже переименуй

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и в других задачах тоже

int GetLefrChildIndex(int i) { return 2 * i + 1; }
int GetRightChildIndex(int i) { return 2 * i + 2; }

void heapify(int i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heapify

#include <vector>

template <class T>
int partition(std::vector<T>& v, int low, int high) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partition

#include <vector>

template <class T>
int partition(std::vector<T>& v, int low, int high) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

та же функция что и в предидущей задаче, давай вынесем в lib/src/utils.hpp

BinaryTree() : root_(nullptr) {}
~BinaryTree() { DestroyTree(root_); }

void insert(int value) { root_ = InsertRecursive(root_, value); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert
и в других местах поправь имена методов по код стайлу

return pair.second;
}
}
throw std::logic_error("No such key in table");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out_of_range

template <class Key, class Value>
void HashTable<Key, Value>::Rehash() {
std::vector<std::list<std::pair<Key, Value>>> new_table(table_.size() * 2);
for (const auto& list : table_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если убрать const в обеих for то можно будет переместить элементы: new_table[index].emplace_back(std::move(pair));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants